package com.zw.pdm.module.overview.controller;

import com.zw.pdm.base.BaseController;
import com.zw.pdm.common.JsonResult;
import com.zw.pdm.module.overview.model.ProChgInfo;
import com.zw.pdm.module.overview.service.ProJectChangeService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * @Author: mac
 * @Date: 2021/3/9 18:39
 */
@Controller
@RequestMapping("/projectChange")
@SuppressWarnings("all")
public class ProJectChangeController extends BaseController {

    @Autowired
    private ProJectChangeService proJectChangeService;

    /**
     * 项目变更通知列表页面
     *
     * @param model
     * @return
     */
    @GetMapping("/chgInfo")
    @RequiresPermissions({"projectChange:home:view"})
    public String infoPage(Model model) {
        return "overview/projectManage/chgInfoList";
    }

    /**
     * 待发变更通知列表
     *
     * @return 列表数据
     */
    @ResponseBody
    @PostMapping("/infoList")
    public JsonResult infoList(ProChgInfo query) {
        startPage();
        List<ProChgInfo> list = proJectChangeService.selectProjectChgInfoList(query);
        return jsonResult(list);
    }

    /**
     * 变更通知查看页面
     * @param proChangeId
     * @param model
     * @return
     */
    @GetMapping("/chgInfo/viewInfo/{proChangeId}")
    public String viewInfoPage(@PathVariable("proChangeId") Integer proChangeId, Model model) {
        ProChgInfo proChgInfo = proJectChangeService.selectChangeInfoByID(proChangeId);
        model.addAttribute("proChgInfo", proChgInfo);
        return "overview/projectManage/chgInfoView";
    }

}
